<?php
/* @var $this ProductController */

$this->breadcrumbs = array(
    'Product',
);
$this->pageTitle = 'Products';
$baseUrl = Yii::app()->request->baseUrl;
$count = 0;
$categories = Category::model()->findAll('1 ORDER BY position ASC');
?>
<div class="row light-gray">
    <div class="row-content pageTitle ">
        <ul>
            <li><a href="<?echo Yii::app()->request->baseUrl?>/">Home page</a> &gt;</li>
            <li>Products</li>
        </ul>
        <h1>
            Products</h1>
    </div>
</div>
<div class="row light-gray">
    <div class="row-content horizontalLayout">
<? 
foreach ($categories as $category) 
{?>
        <div class="horizontalBox  <? echo ($count%2==0)?'leftMode':'rigthMode'; ?>">
            <img src="<? echo $baseUrl.'/protected/uploads/images/'.$category->image?>" class="mainImage" />
            <div class="content">
                <h2>
                    <? echo $category->name ?></h2>
                <p>
                    <? echo $category->description ?>
                </p>
                <ul>
                    <?
                    foreach ($category->products as $product){ ?>    
                    <li><a href="<? echo $this->createUrl('detail',array('id'=>$product->id))?>">
                            <? echo CHtml::image($baseUrl.'/protected/uploads/images/products/'.$product->image_thumb, $product->name.' image');?>
                            <span class="name"><? echo $product->name; ?></span>
                            </a>
                        </li>
                    <?}
                    ?>
                    
                </ul>
            </div>
        </div>
<?
    $count++;
}
?>
    </div>
</div>